#ifndef SECURITYMANAGER_H
#define SECURITYMANAGER_H

#include <plugin/plugin_global.h>
#include <plugin/util/AbstractPrincipal.h>
#include <plugin/util/AbstractSecurityContextHandler.h>

namespace antu
{
namespace plugin
{
class PLUGINSHARED_EXPORT SecurityManager
{
public:
    SecurityManager();
    virtual ~SecurityManager();

    AbstractPrincipal* currentPrincipal();
    void login(const QString& credential, const QString& token);

    virtual QString licenseRequest() const = 0;
    virtual QString license() const = 0;

    bool isAllowed(const QString& moduleCode) const;
    bool isAllowed(const QString& moduleCode, const QString& unit) const;

    void setSecurityHandler(AbstractSecurityContextHandler* pHandler);

protected:
    AbstractPrincipal* m_pPrincipal;
    AbstractSecurityContextHandler* m_pSecurityHandler;

    virtual AbstractPrincipal* authenticate(const QString& credential, const QString& token) = 0;
};

}
}


#endif // SECURITYMANAGER_H
